﻿
@{
    ViewBag.Title = "签订合同详情";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<style type="text/css">
    .form .formValue input.form-control {
        height: 32px;
        line-height: 32px;
        padding: 0px;
        resize: none;
        border-radius: 0px;
        box-shadow: none;
        text-indent: 5px
    }

    .textValue {
        width: 100%;
    }

    .selectbox {
        color: #444;
        line-height: 34px;
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        height: 34px;
        width: 100%;
    }

    .search {
        margin-left: 10px;
        padding: 0px;
    }

    table td {
        height: 40px;
        line-height: 40px;
    }

    .zdyPanel {
        background-color: #fff;
        border-top: 1px solid #ddd;
        border-left: 1px solid #ddd;
        border-right: 1px solid #ddd;
        margin: 0px;
        float: left;
        width: 100%;
    }

    .zdyTool {
        float: left;
        padding-left: 10px;
        width: 100%;
    }

    .zdyBar {
        padding: 0px;
        margin: 0px;
        margin-top: 3px;
    }

    .zdyUL {
        list-style-type: none;
        margin: 5px 0px 0px -3px;
        padding: 0px;
    }

        .zdyUL li {
            float: left;
            list-style: none;
            height: 24px;
            line-height: 22px;
        }

            .zdyUL li a {
                cursor: pointer;
                padding: 5px 10px;
                border-radius: 4px;
            }

            .zdyUL li i {
                margin-right: 4px;
                font-size: 13px;
                color: #666;
                vertical-align: middle;
                margin-top: -1px;
            }

            .zdyUL li a:hover {
                text-decoration: none;
                background-color: #1ABC9C;
                color: #fff;
            }

    .zdyGirdPanel {
        width: 100%;
        margin: 0px;
        padding: 0px;
        float: left;
    }

    .zdyContentPanel {
        width: 100%;
        margin: 5px 0px 0px 0px;
        padding: 0px;
        float: left;
    }

    .zdyFont {
        padding-left: 5px;
        color: #ff6a00;
    }

    .autocomplete-suggestions {
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        border: 1px solid #999;
        background: #FFF;
        cursor: default;
        overflow: auto;
        -webkit-box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
        -moz-box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
        box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
    }

    .autocomplete-selected {
        background: #F0F0F0;
    }

    .autocomplete-suggestion {
        padding: 2px 5px;
        white-space: nowrap;
        overflow: hidden;
    }

    .autocomplete-no-suggestion {
        padding: 2px 5px;
    }

    .zdyUL {
        list-style-type: none;
        margin: 5px 0px 0px -3px;
        padding: 0px;
    }

        .zdyUL li {
            float: left;
            list-style: none;
            height: 24px;
            line-height: 22px;
        }

            .zdyUL li a {
                cursor: pointer;
                padding: 5px 10px;
                border-radius: 4px;
            }

            .zdyUL li i {
                margin-right: 4px;
                font-size: 13px;
                color: #666;
                vertical-align: middle;
                margin-top: -1px;
            }

            .zdyUL li a:hover {
                text-decoration: none;
                background-color: #1ABC9C;
                color: #fff;
            }

    .zdyGirdPanel {
        padding-top: 3px;
    }

    .form .formValue {
        padding: 1px 3px;
    }
</style>

<div class="zdyGirdPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>

<script>
    var orderId = $.request("F_OrderId");
    var checkId = $.request("F_Id");
    var F_FlowId = $.request("F_FlowId");
    var ApplyType = $.request("ApplyType");
    var F_CheckUserId = $.request("F_CheckUserId");
    var F_No = $.request("F_No");

    $(function () {
        initGridList();
    });

    //初始化列表数据
    function initGridList() {
        var $gridList = $("#gridList");

        $gridList.dataGrid({
            url: "/CheckManager/CheckInfos/GetOrderSignContractDetailGridJson",
            postData: { keyValue: orderId, userId: F_CheckUserId, F_No: F_No},
            height: 500,
            colModel: [
                {
                    label: '场地名称', name: 'F_SiteName', width: 100
                },
                {
                    label: '空间名称', name: 'F_SpaceName', align: 'left', width: 100
                },
                {
                    label: '预定起止时间', name: 'StartingAndEndingDate', align: 'left', width: 250
                },                
                {
                    label: '备注', name: 'F_Remark', align: 'left', width: 180
                },
                {
                    label: '合同文件', name: 'F_FileName', align: 'left', width: 150, formatter: function (cellvalue, options, rowObject) {
                        return "<a href=\"" + rowObject["F_FilePath"] + "\" class=\"btn btn-success btn-xs\"><span class=\"glyphicon glyphicon-download-alt\"></span></a>&nbsp;&nbsp;" + cellvalue +"";
                    }
                },
                {
                    label: '操作', name: 'F_OrderSignContractId', width: 100, align: 'center',
                    formatter: function (cellvalue, options, rowObject) {
                        if (rowObject["F_State"] == 1) {
                            return "<span style=\"color:#1ABC9C;\">已同意</span>";
                        } else if (rowObject["F_State"] == 2) {
                            return "<span style=\"color:red;\">已驳回</span>";
                        }

                        return '<div class="btn-group btn-group-xs" style="margin-top:5px;">'
                            + '   <button type="button" class="btn btn-link" onclick="btn_agree(\'' + cellvalue + '\', 0)">审核通过</button>'
                            + '   <button type="button" class="btn btn-link" onclick="btn_reject(\'' + cellvalue + '\')">驳回</button>'
                            + '</div>';
                    }
                }
            ],
            pager: "#gridPager",
            viewrecords: true,
            multiselect: false,
            sortname: 'F_Id'
        });
    }

    var resultData = {};
    function getItemList() {
        resultData = getCache("CHECK_ORDERSIGN");
        if (!resultData || resultData.length <= 0) {
            $.ajax({
                url: "/CheckManager/CheckInfos/GetRejectSignContractDictionaryItemsJson",
                dataType: "json",
                async: false,
                success: function (data) {
                    if (data.bhly.length > 0) {
                        for (var i = 0; i < data.wdqly.length; i++) {
                            $("#F_Reason").append("<option value='" + data.wdqly[i].F_ItemCode + "'>" + data.wdqly[i].F_ItemName + "</option>");
                        }
                    }
                    setCache("CHECK_ORDERSIGN", data);
                }, error: function (XMLHttpRequest, textStatus, errorThrown) {

                }
            });
        } else {
            var data = resultData;
            if (data.bhly.length > 0) {
                for (var i = 0; i < data.wdqly.length; i++) {
                    $("#F_Reason").append("<option value='" + data.wdqly[i].F_ItemCode + "'>" + data.wdqly[i].F_ItemName + "</option>");
                }
            }
        }
    }

    //刷新列表
    function refreshGridList() {
        var $gridList = $("#gridList");

        $gridList.jqGrid('setGridParam',
            {
                keyValue: orderId, userId: F_CheckUserId, F_No: F_No
            }).trigger('reloadGrid');
    }

    //同意
    function btn_agree(id) {
        $.modalConfirm('是否审核通过？', function (flag) {
            if (flag) {
                $.submitForm({
                    url: "/CheckManager/CheckInfos/ConfirmSignContract?orderSignContractId=" + id + "&state=" + 1 + "&checkId=" + checkId + "&F_FlowId=" + F_FlowId + "&ApplyType=" + ApplyType + "&F_CheckUserId=" + F_CheckUserId +"",
                    param: {
                        remark: ''
                    },
                    success: function (data) {
                        refreshGridList();
                    },
                    close: false
                });
            }

            return false;
        });

    }

    //驳回
    function btn_reject(id) {
        $.modalOpen({
            id: "checkSchedule",
            title: "驳回签订合同详情",
            url: "/CheckManager/CheckInfos/RejectSignContractForm?orderSignContractId=" + id + "&checkId=" + checkId + "&F_FlowId=" + F_FlowId + "&ApplyType=" + ApplyType + "&F_CheckUserId=" + F_CheckUserId +"",
            width: "400px",
            height: "165px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }


</script>


